package com.jy.appmarket.model;

import java.io.Serializable;

import com.jy.appmarket.download.DownloadItem;

import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * 类说明 app列表中app的信息model
 * 
 * @author liumj
 * @version1.0
 * @date 2014.04.30
 * 
 **/
public class AppInfoModel implements Serializable, Parcelable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// 应用名称
	private String mName;
	// 应用分类id
	private String mCategory;
	// 应用描述
	private String mDesc;
	// 应用下载地址
	private String mDownloadUrl;
	// 应用包名
	private String mPackageName;
	// 应用图标地址
	private String mPic;
	// 应用评分等级
	private String mRating;
	// 应用大小
	private long mSize;
	// 当前下载的大小
	private long mCurrentDownloadSize;

	// 当前下载人数
	private String mDownloads;

	// 是否已经安装
	private boolean isInstalledApp = false;
	// 已经安装的app的图标
	private Drawable drawable;

	// 是否选中
	private boolean isSelected;
	
	

	private int mState;
	private long mDownloadedSize;
	
	private String versionName;
	private int versionCode;
	private String md5;
	private transient DownloadItem mDownloadModel;
	
	private transient String mDlIt;
	
	
	public boolean isInstalledApp() {
		return isInstalledApp;
	}

	public void setInstalledApp(boolean isInstalledApp) {
		this.isInstalledApp = isInstalledApp;
	}

	public String getName() {
		return mName;
	}

	public void setName(String mName) {
		this.mName = mName;
	}

	public String getCategory() {
		return mCategory;
	}

	public void setCategory(String mCategoryId) {
		this.mCategory = mCategoryId;
	}

	public String getDesc() {
		return mDesc;
	}

	public void setDesc(String mDesc) {
		this.mDesc = mDesc;
	}

	public String getDownloadUrl() {
		return mDownloadUrl;
	}

	public void setDownloadUrl(String mDownloadUrl) {
		this.mDownloadUrl = mDownloadUrl;
	}

	public String getPackageName() {
		return mPackageName;
	}

	public void setPackageName(String mPackageName) {
		this.mPackageName = mPackageName;
	}

	public String getPic() {
		return mPic;
	}

	public void setPic(String mPic) {
		this.mPic = mPic;
	}

	public String getRating() {
		return mRating;
	}

	public void setRating(String mRating) {
		this.mRating = mRating;
	}

	public long getSize() {
		return mSize;
	}

	public void setSize(long mSize) {
		this.mSize = mSize;
	}

	public long getCurrentDownloadSize() {
		return mCurrentDownloadSize;
	}

	public void setCurrentDownloadSize(long mCurrentDownloadSize) {
		this.mCurrentDownloadSize = mCurrentDownloadSize;
	}

	public String getDownloads() {
		return mDownloads;
	}

	public void setDownloads(String mDownloads) {
		this.mDownloads = mDownloads;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public int getState() {
		return mState;
	}

	public void setState(int state) {
		this.mState = state;
	}

	public long getDownloadedSize() {
		return mDownloadedSize;
	}

	public void setDownloadedSize(long downloadedSize) {
		this.mDownloadedSize = downloadedSize;
	}

	
	public void setDownloadId(String dlId){
		mDlIt = dlId;
	}
	
	public String getDownloadId(){
		return mDlIt;
	}
	
	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(mName);
		dest.writeString(mCategory);
		dest.writeString(mDesc);
		dest.writeString(mDownloadUrl);
		dest.writeString(mPackageName);
		dest.writeString(mPic);
		dest.writeString(mRating);
		dest.writeLong(mSize);
		dest.writeLong(mCurrentDownloadSize);

		dest.writeString(mDownloads);
		if (isInstalledApp) {
			dest.writeInt(1);
		} else {
			dest.writeInt(0);
		}

		if (isSelected) {
			dest.writeInt(1);
		} else {
			dest.writeInt(0);
		}
		dest.writeInt(mState);
		dest.writeLong(mDownloadedSize);
		dest.writeString(versionName);
		dest.writeInt(versionCode);
		dest.writeString(md5);
	}

	public Drawable getDrawable() {
		return drawable;
	}

	public void setDrawable(Drawable drawable) {
		this.drawable = drawable;
	}

	public String getVersionName() {
		return versionName;
	}

	public void setVersionName(String versionName) {
		this.versionName = versionName;
	}

	public int getVersionCode() {
		return versionCode;
	}

	public void setVersionCode(int versionCode) {
		this.versionCode = versionCode;
	}

	public DownloadItem getmDownloadModel() {
		return mDownloadModel;
	}

	public void setmDownloadModel(DownloadItem mDownloadModel) {
		this.mDownloadModel = mDownloadModel;
	}

	public String getMd5() {
		return md5;
	}

	public void setMd5(String md5) {
		this.md5 = md5;
	}

	public static final Parcelable.Creator<AppInfoModel> CREATOR = new Parcelable.Creator<AppInfoModel>() {
		@Override
		public AppInfoModel createFromParcel(Parcel source) {
			AppInfoModel app = new AppInfoModel();
			app.setName(source.readString());
			app.setCategory(source.readString());
			app.setDesc(source.readString());
			app.setDownloadUrl(source.readString());
			app.setPackageName(source.readString());
			app.setPic(source.readString());
			app.setRating(source.readString());
			app.setSize(source.readLong());
			app.setCurrentDownloadSize(source.readLong());
			app.setInstalledApp(source.readInt() == 1);
			app.setSelected(source.readInt() == 1);
			app.setState(source.readInt());
			app.setDownloadedSize(source.readLong());
			app.setVersionName(source.readString());
			app.setVersionCode(source.readInt());
			app.setMd5(source.readString());
			return app;
		}

		@Override
		public AppInfoModel[] newArray(int size) {
			return new AppInfoModel[size];
		}
	};

}
